package org.zxy.org.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.zxy.base.util.PageList;
import org.zxy.org.domain.Department;
import org.zxy.org.mapper.DepartmentMapper;
import org.zxy.org.query.DepartmentQuery;
import org.zxy.org.service.IDepartmentService;

import java.util.List;

@Service
public class DepartmentServiceImpl implements IDepartmentService {

    @Autowired
    private DepartmentMapper departmentMapper;

    @Transactional
    @Override
    public void save(Department department) {
        departmentMapper.save(department);
    }

    @Transactional
    @Override
    public void deleteById(Long id) {
        departmentMapper.deleteById(id);
    }

    @Transactional
    @Override
    public void update(Department department) {
        departmentMapper.update(department);
    }

    @Override
    public Department selectById(Long id) {
        return departmentMapper.selectById(id);
    }

    @Override
    public List<Department> selectAll() {
        return departmentMapper.selectAll();
    }


    @Override
    public PageList<Department> queryPage(DepartmentQuery departmentQuery) {
        Long total = departmentMapper.queryTotal(departmentQuery);
        List<Department> list = departmentMapper.queryPage(departmentQuery);
        return new PageList<Department>(total, list);
    }


    @Override
    public List<Department> queryDeptTree() {
        return departmentMapper.queryDeptTree();
    }

    @Transactional
    @Override
    public void batchDelete(List<Long> ids) {
        departmentMapper.batchDelete(ids);
    }
}
